/*
 * Copyright (c) 2022  by Junzhao
 * THIS FILE IS PART OF JAVASE Song Huongkang PROJECT
 * All Rights Reserved.
 */

package 优先级;
/**
 * @description 并不是优先级高就一定先执行完 ！
 * @author 俊昭
 * @date 2022/4/12
*/
public class PriorityTest {
    public static void main(String[] args) {
        MyThread1 myThread1 = new MyThread1("优先级");
        myThread1.setPriority(Thread.MAX_PRIORITY);
        System.out.println(myThread1.getPriority());




        myThread1.start();




        Thread.currentThread().setName("主线程");
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        System.out.println(Thread.currentThread().getPriority());
        for (int i = 0 ;i<200;i++){
            if (i % 2 == 1){
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
}
class MyThread1 extends Thread{


    public MyThread1(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0 ;i<200;i++){
            if (i % 2 == 1){

//                try {
//                    Thread.sleep(10);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }

                System.out.println(getName()+":"+i);
            }
        }
    }
}